<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>财务开票</title>
    <script src="http://code.jquery.com/jquery-3.4.1.min.js"
            integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
            crossorigin="anonymous"></script>
    <jsp:include page="../../import.jsp" flush="true"/>
    <jsp:include page="activeX4Invoice.jsp" flush="true"/>
    <OBJECT ID=sk
            CLASSID="clsid:003BD8F2-A6C3-48EF-9B72-ECFD8FC4D49F"
            codebase="NISEC_SKSCX.ocx#version=1,0,0,1" style="display: none">
    </OBJECT>
</head>
<body class="iframeBody">

<div class="Wrapper">
	<div>
            <div id="pageInTab" class="pageInTab">
                    <form id="cust_auditing_add_form">
                        <div class="fieldset1 tabel_col clearFix">
                            <div class="fieldBox col_33">
                                <div class="label">客户名称</div>
			                    <div class="field">
			                        <input name="cstNm" id="cstNm" disabled="disabled" type="text" class="ui-textbox" value="" validate="{required:true}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
                            </div>
                            <div class="fieldBox col_33">
			                    <div class="label">项目所属机构</div>
			                    <div class="field">
			                        <input name="orgNm" id="orgNm" disabled="disabled" type="text" class="ui-textbox" validate="{required:true}">
			                    </div>
			                </div>
                            <div class="fieldBox col_33">
                                <div class="label">收件人</div>
			                    <div class="field">
			                        <input name="rcverNm" id="rcverNm" type="text" class="ui-textbox" value="" placeholder="无特殊情况,请填写商助姓名." validate="{required:true, maxlength:10}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
                            </div>
                            <div class="fieldBox col_33">
			                     <div class="label">联系电话</div>
						        <div class="field">
						           <input name="rcverTel" id="rcverTel" type="text" class="ui-textbox" value="" placeholder="无特殊情况,请填写商助电话." validate="{required:true, maxlength:15}">
						           <span class="requiredSymbol">*</span>
						        </div>
			                </div>
			                <div class="fieldBox col_33">
			                     <div class="label">流程发起人姓名</div>
						        <div class="field">
						         	<input name="sysUsrRlNm" id="sysUsrRlNm" type="text" disabled="disabled" class="ui-textbox" value="" validate="{required:true, maxlength:10}">
						        </div>
			                </div>
			                 <div class="fieldBox col_33">
			                     <div class="label">流程发起人联系电话</div>
						        <div class="field">
						        	<input name="sysUsrMp" id="sysUsrMp" type="text" disabled="disabled" class="ui-textbox" value="" validate="{required:true, maxlength:15}">
						        </div>
			                </div>
			                <div class="fieldBox col_66">
			                    <div class="label">收件地址</div>
			                    <div class="field">
			                        <input name="rcvAddr" id="rcvAddr" type="text" class="ui-textbox" value="" placeholder="无特殊情况,请填写商助地址." validate="{required:true, maxlength:60}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
			                </div>
                            <div class="fieldBox col_33">
                                <div class="label">开具方式</div>
                                <div class="field">
                                    <input name="billWayCd" id="billWayCd" type="text" class="ui-textbox" value="纸质发票" disabled>
                                </div>
                            </div>
			                <div class="fieldBox col_33">
                                <div class="label">快递公司</div>
			                    <div class="field">
			                        <input name="expCorp" id="expCorp" type="text" class="ui-textbox" value="" validate="{required:true, maxlength:25}">
			                        <span class="requiredSymbol">*</span>
			                    </div>
                            </div>
                            
                            <div class="fieldBox col_33">
                                <div class="label">快递单号</div>
			                    <div class="field">
			                        <input name="trcNo" id="trcNo" type="text" class="ui-textbox" value="" >
			                    </div>
                            </div>
                            
                            <div class="fieldBox col_33">
			                    <div class="label">是否提前开票</div>
			                    <div class="field">
			                    	<span id="isPreInvNm" name="isPreInvNm"></span>
			                    </div>
			                </div>
			                
			                <div class="fieldBox col_33">
			                     <div class="label">开票人电话</div>
						        <div class="field">
						           <input name="invTel" id="invTel"  disabled="disabled" type="text" class="ui-textbox" value="" validate="{required:false, maxlength:15}">
						        </div>
			                </div>
			                
			                <div class="fieldBox col_33">
			                    <div class="label">开票人开户行</div>
			                    <div class="field">
			                         <select name="invBkCd" id="invBkCd" data-value="" validate="{required:false, select: false}">
			                            <option value="">请选择</option>
			                            <c:forEach items="${selectBkCdList }" var="kv">
											<option value="${kv.key }">${kv.value }</option>
										</c:forEach>
			                		 </select>
			                    </div>
			                </div>
			                
				            <div class="fieldBox col_33">
			                     <div class="label">开票人帐号</div>
						        <div class="field">
						           <input name="invAccNo" id="invAccNo"  disabled="disabled" type="text" class="ui-textbox" value="" validate="{required:false, maxlength:30}">
						        </div>
			                </div>	
			                
			                <div class="fieldBox col_33">
			                     <div class="label">纳税人识别号</div>
						        <div class="field">
						           <input name="invTaxId" id="invTaxId"  disabled="disabled" type="text" class="ui-textbox" value="" validate="{required:false, maxlength:30}">
						        </div>
			                </div>
                            <div class="fieldBox col_33">
                                <div class="label">客户类型</div>
                                <div class="field">
                                    <input name="cstTypCdNm" id="cstTypCdNm"  disabled="disabled" type="text" class="ui-textbox" value="" >
                                </div>
                            </div>

                            <div class="fieldBox col_100">
			                    <div class="label">发票抬头</div>
			                    <div class="field">
			                        <input name="invTitle" id="invTitle"  disabled="disabled" type="text" class="ui-textbox" value="${cstNm }" validate="{required:false, maxlength:20}">
			                    </div>
			                </div>
			                
			                <div class="fieldBox col_100">
			                    <div class="label">开票地址</div>
			                    <div class="field">
			                        <input name="invAddr" id="invAddr" disabled="disabled" type="text" class="ui-textbox" value="" validate="{required:false, maxlength:100}">
			                    </div>
			                </div>
			          
							<div class="fieldBox col_100">
									<div class="label">资料</div>
									<div class="field">
					                	<jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true" >
					                   		<jsp:param name="pkId" value="${id }"/>
					                   		<jsp:param name="tabNm" value="PRJ_BILL_APPLY"/>
					                 	</jsp:include>
					                 	<span style="color: red;">提示:若申请开具增值税专用发票,需要上传营业执照或承租人开票信息附件.</span>
						            </div>
							</div>
                            
			                 <!-- hide data -->
					        <div class="fieldBox col_100" style="display:none;">
					          <div class="field">
					              <input name="applyId" id="applyId" type="text" class="ui-textbox" value="${id}">
					              <input name="orgCd" id="orgCd" type="text" class="ui-textbox" value="${orgCd}">
					          	  <input name="isPreInv" id="isPreInv" type="text" class="ui-textbox" value="">
					          </div>
					        </div>
                        </div>	
                    </form>
                    <div class="sqPanel">
                        <div class="sqPanel_head inL">
                            <c:if test="${'1' != mdf}">
                                <div class="btnsBox inLC">
                                    <span id="issueReceipt" onclick="issueInvoiceOrReceipt('1');" class="sq-button sq-button-round">开具收据</span>
                                    <span id="issueInvoice" onclick="issueInvoiceOrReceipt('2');" class="sq-button sq-button-round">开具发票</span>
                                </div>
                            </c:if>
                            <span>支付表信息</span>
                            <div class="fieldset1 clearFix">
                                <div class="fieldBox">
                                    <div class="label"></div>
                                    <div class="field">
                                        <input name="feeTypList" id="feeTypList" data-value="" placeholder="请选择费用项" ltype="combobox">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- 支付表列表 -->
						<div id="invoiceAddGrid" class="sq-grid"></div>
                    </div>
            </div>
            <c:if test="${'1' == mdf}">
                <div class="btnsBox" style="text-align: center">
                    <span id="modifyInvoiceBtn" class="sq-button sq-button-round" onclick="modifyInvoice()">保存</span>
                </div>
            </c:if>
        </div>
</div>


	<!-- 验证状态窗口-->
	<div id="div_auditing_save_win_id" style="display:none">
		<form id="div_auditing_save_win_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
			    <div class="fieldBox col_100">
			         <div class="label">开票类型</div>
			         <div class="field">
			               <select name="billTypCd" id="billTypCd" data-value="" validate="{required:true, select: true}">
		                        <c:forEach items="${prjBillStsCdList }" var="vs" begin="0" step="1" varStatus="status">
										 <option value="${vs.key }" >${vs.value }</option>
		                        </c:forEach>
		                    </select>
			              <span class="requiredSymbol">*</span>
			         </div>
			   </div>
			</div>
        </form>
	</div>

    <div id="div_auditing_save_win_id_receipt" style="display:none">
        <form id="div_auditing_save_win_form_receipt">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_100">
                    <div class="label">票据号</div>
                    <div class="field">
                        <input name="billNo" id="billNo" type="text" class="ui-textbox" value="" validate="{required:true, maxlength:30}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
            </div>
        </form>
    </div>
		
	<script>
		$(function() {
            initGrid();
            initForm();
            initData();

            $("#feeTypList").ligerComboBox({
                valueField: 'key',
                textField: 'value',
                width: 150,
                data: ${feeTyps},
                onChangeValue: function () {
                    searchFeeTyp();
                }
            });
		});

        function searchFeeTyp() {
            if (!invoiceAddGrid) return null;

            // invoiceAddGrid.loadData(invoiceAddGrid.getData());
            var clause = function (rowdata, rowindex) {
                var key = liger.get("feeTypList").getValue();
                if (key) {
                    return rowdata.feeTypCd == (key);
                } else {
                    return true;
                }
            };
            invoiceAddGrid.loadData(clause);
        }

		//初始化表单
		function initForm() {
			$("#cust_auditing_add_form").ligerForm({
				validate : true
			});
			$("#div_auditing_save_win_form").ligerForm({
				validate : true
			});
            $("#div_auditing_save_win_form_receipt").ligerForm({
                validate : true
            });
		}

		var invoiceAddGrid;

		//初始化列表
		function initGrid() {
			var _applyId = $("#applyId").val();
			var billTypCdList = [];//模块类型数据

            $("#invoiceAddGrid").ligerGrid({
				usePager : false,
				url : "<%=path%>/invoice/prjbillfeer/initList.do?applyId="+_applyId,
	            method : 'get',
	            columns: [{
	            	display: '业务模式', 
	            	name: 'bizTypCdNm', 
	            	width: 180, 
	            	align: 'center'
	            },{
	                display: '支付表号',
	                name: 'paySchNo',
	                width: 200,
	                align:'center',
	                render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            		    h='<a href="javascript:detailBtn(';
	                        h+="'"+rowdata.id+"',";
	                        h+="'"+rowdata.paySchId+"',";
	                        h+=')">'+value+'</a>'
	                        return h;
	            		},
	            }, {
	                display: '费用项',
	                name: 'feeTypCdNm',
	                width: 150,
	                align:'center'
	            }, {
	                display: '资金流向',
	                name: 'capFlowNm',
	                width: 100,
	                align:'center'
	            }, {
	                display: '应收金额(元)',
	                name: 'billAmt',
	                width: 120,
	                align:'right',
	                render:function(rowdata,index,value){
	                    return '&yen;' + FormatMoney(rowdata.billAmt/100);
	                }
	            }, {
	                display: '实收金额(元)',
	                name: 'billAmt',
	                width: 120,
	                align:'right',
	                render:function(rowdata,index,value){
	                    return '&yen;' + FormatMoney(rowdata.billAmt/100);
	                }
	            }, {
	                display: '开票类型',
	                name: 'billTypCdNm',
	                width: 150,
	                align:'center'
	            }, {
	                display: '票据状态',
	                name: 'billStsCdNm',
	                width: 100,
	                align:'center'
	            }, {
	                display: '票据号',
	                name: 'billNo',
	                width: 160,
	                align:'left',
                    editor: { type: 'text'}
	            },getGridOperColumnContent()],
	            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
	                /* if (e.selected && e.column.columnname == "billTypCdNm") {
	                    e.record.billTypCd = e.value;
	                    e.value = e.selected[e.column.editor.textField];
	                } */
	            },
	            isDisabledSelect: function (item) {
	                if (StringUtils.isNotEmpty(item.billStsCd) && item.billStsCd == CustomerConstant.CODE_PRJ_BILL_STS_CD_2) {
	                	return true;
	                }
	                
	                if(item.isDel == CustomerConstant.CODE_PRJ_BILL_R_IS_DEL_2){
	                	return true;
	                }
	            },
                onSuccess: function (data, grid) {
                    grid.loadData(data);
                },
                onReload: function(grid){
				    grid.reload();
                },
	            width: '100%',
	            //height:'100%',
				heightDiff:-2,
	            root:'rows',
		        record:'total',
	            rownumbers: true,
	            enabledEdit: false,
	            checkbox:true,
	            fixedCellHeight: false,
	            usePagerOnLessPagesize: false,
	            onAfterShowData: function(currentData) {
	                SetIframe_height();
	                $(".liger_tip").ligerTip();
	            }
	        });

            invoiceAddGrid = liger.get("invoiceAddGrid");
	        //grid.setHeight(100);
            invoiceAddGrid.options.isSingleCheck=false;
	    }
		
	  //获取Grid操作列内容
	    function getGridOperColumnContent(){
	    	 var data = {
	            display: '操作',
	            isSort: false,
	            align:'left',
	            width: 180,
	            render: function (rowdata, rowindex, value){
	            	var h= "";
	            	if (StringUtils.isNotEmpty(rowdata.billStsCd) && rowdata.billStsCd == CustomerConstant.CODE_PRJ_BILL_STS_CD_2) {
	                	//为作废状态
	                }else if(StringUtils.isNotEmpty(rowdata.billStsCd) && rowdata.billStsCd == CustomerConstant.CODE_PRJ_BILL_STS_CD_1) {
	                	 // h+='<a class="sq-button-hasicon" alt="作废" href="javascript:stopUsedZF(';
		                 // h+="'"+rowdata.id+"'";
		                 // h+=",'"+rowdata.billId+"'";
		                 // h+=")\"><i class=\"sqBtnIco_5\"></i>"+LogUtils.LOG_CMM_GRID_BTN_ZF+"</a>"
	                }else{
	                	if(rowdata.isDel == CommonConstant.C_YN_N){
		                	h+='<a class="sq-button-hasicon" alt="不需要开票可以操作,操作后可以恢复数据到可开票状态。" href="javascript:delRow(';
		                    h+="'"+rowdata.id+"'";
		                    h+=")\"><i class=\"sqBtnIco_11\"></i>"+LogUtils.LOG_CUST_GRID_INVOICE_NO_NEED+"</a>"
	               		}
	                    if(rowdata.isDel == CustomerConstant.CODE_PRJ_BILL_R_IS_DEL_2){//需要恢复删除数据2为正常状态0
	                    	 h+='<a class="sq-button-hasicon" alt="恢复" href="javascript:backNormalRow(';
	 	                    h+="'"+rowdata.id+"'";
	 	                    h+=")\"><i class=\"sqBtnIco_48\"></i>"+LogUtils.LOG_CMM_GRID_BTN_BACK+"</a>"
	                    }
	                }
	                return h;
	            }
	    	 }
	    	return data;
	    }
		
		//保存
		function issueInvoiceOrReceipt(type){
            //获取Grid数据
            var _grid = invoiceAddGrid.getSelectedRows();
            if(_grid.length == 0){
                UIUtils.alertWarning(LogUtils.LOG_CMM_SELECT_MORE_ROW);
                return;
            }
		    var title;
		    var target;
		    var formId;
		    var url;
		    if ("1" == type) {
		        title = "开收据";
		        target = "#div_auditing_save_win_id_receipt";
		        formId = "div_auditing_save_win_form_receipt";
		        url = '<%=path%>/invoice/prjbillapply/applyInvoice.do';
            } else if ("2" == type) {
                for ( var index in _grid) {
                    if ('4' == _grid[index].billTypCd) {
                        UIUtils.alertWarning("开票类型为收据不能开发票");
                        return;
                    }
                    if ('0' == _grid[index].billStsCd || '1' == _grid[index].billStsCd) {
                        UIUtils.alertWarning("开票中/正常不能开发票");
                        return;
                    }
                }
                title = "开票";
                target = "#div_auditing_save_win_id";
                formId = "div_auditing_save_win_form";
                url = '<%=path%>/invoice/prjbillapply/applyInvoice.do';
            }
			var ligerForm = liger.get("cust_auditing_add_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                return false; //验证不通过，不执行以下代码
            }
            var _data = [];
            for ( var index in _grid) {
                _data.push(_grid[index].id);
            }
            var formData = ligerForm.getData();
    		formData["invoiceAddGrid"] = JSON.stringify(_data);
    		//弹出一个窗口录入开票类型和票据号
    		$.ligerDialog.SQopen({
                cls: 'noBorder_Dialog',
                width: 600,
                height: 120,
                title: title,
                target: $(target),
                buttons: [
                    {
                        text: "保存", cls: 'l-dialog-btn-ok', onclick: function () {
                            if ("2" == type) {
                                var returnKeyQuery;
                                // 校验税控钥匙信息
                                $.ajax({
                                    type: 'post',
                                    dataType: 'json',
                                    data: {operFlag: "1"},
                                    async: false,
                                    url: '<%=path%>/invoice/prjbillapply/getInvoiceXml.do',
                                    success: function (msg) {
                                        if (msg.success == 1) {
                                            var keyQueryXml = msg.data[0];
                                            returnKeyQuery = keyQuery(keyQueryXml);
                                        } else {
                                            $.ligerDialog.SQalert({content: "获取校验税控钥匙信息报文失败", SQ_type: "error"});
                                        }
                                    }
                                });
                                if (!returnKeyQuery) {
                                    return returnKeyQuery;
                                }
                            }
                            var auditinWinForm = liger.get(formId);
                            if (!auditinWinForm.valid()) {
                                UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                                return false; //验证不通过，不执行以下代码
                            }
                            if(_grid.length == 0){
                                top.$.ligerDialog.SQalert({content: "请选择需要开票的费用项数据！", SQ_type: "warning"});
                                return false;
                            }
                            formData["paySchFeeList"] = JSON.stringify(_grid);
                            var auditinWinFormData = auditinWinForm.getData();
                            var saveData = $.extend({}, formData, auditinWinFormData);
                            //alert(JSON.stringify(saveData));
                            if ("1" == type) {
                                saveData["billTypCd"] = "4";
                                AjaxUtils.ajaxPost(url, saveData, saveCallback1);
                            } else if ("2" == type) {
                                AjaxUtils.ajaxPost(url, saveData, saveCallback);
                            }
                        }
                    }, {
                        text: "取消", cls: 'l-dialog-btn-no', onclick: function () {
                            $.ligerDialog.hide();
                        }
                    }
                ]
            });
		}

        // 新增回调（收据）
        function saveCallback1(msg){
            if(msg.success == 1){
                // $.ligerDialog.close();
                // grid.reload();
                // UIUtils.alertSuccess(msg.info);

                $.ligerDialog.hide();
                UIUtils.alertSuccess(msg.info);
                var _applyId = $("#applyId").val();
                invoiceAddGrid.setParm("applyId",_applyId);
                var url = "<%=path%>/invoice/prjbillfeer/initList.do";
                AjaxUtils.ajaxGet(url, {applyId:_applyId}, function (msg) {
                    var data = msg.rows;
                    invoiceAddGrid.loadData({rows:data});
                });
                // var _applyId = $("#applyId").val();
                // grid.setParm("applyId",_applyId);

                // $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                // setTimeout(function(){ $.ligerDialog.close(); }, 1500);
                // grid.reload();
            }else{
                UIUtils.alertError(msg.info);
            }
        }
		
		// 新增回调（发票）打印
		function saveCallback(msg) {
            if (msg.success == 1) {
                var bscInfo = msg.data;
                var bscInfoId = bscInfo.id;
                var invoiceCode = bscInfo.invoiceCode;
                var billNo = bscInfo.billNo;
                $.ligerDialog.close();
                var _applyId = $("#applyId").val();
                invoiceAddGrid.setParm("applyId", _applyId);
                var url = "<%=path%>/invoice/prjbillfeer/initList.do";
                AjaxUtils.ajaxGet(url, {applyId: _applyId}, function (msg) {
                    var data = msg.rows;
                    invoiceAddGrid.loadData({rows: data});
                });
                $.ligerDialog.confirm("发票代码：" + invoiceCode + "票据号：" + billNo + "。是否打印发票", function (flag) {
                    if (flag == false) return;
                    // 调用ActiveX打印发票
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: {operFlag: "2", bscInfoId: bscInfoId},
                        url: '<%=path%>/invoice/prjbillapply/getInvoiceXml.do',
                        success: function (msg) {
                            if (msg.success == 1) {
                                var paramSet = msg.data[0];
                                var pageSet = msg.data[1];
                                var printSet = msg.data[2];
                                var printResult = printInvoiceByActiveX(paramSet, pageSet, printSet);
                                if (!printResult) {
                                    UIUtils.alertError("发票打印失败，请检查税控钥匙");
                                    return false;
                                }
                                UIUtils.alertSuccess(msg.info);
                            } else {
                                $.ligerDialog.SQalert({content: "获取发票打印报文失败", SQ_type: "error"});
                            }
                        }
                    });
                });
            } else {
                $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
            }

        }

		//作废
		function stopUsedZF(_id, _billId){
			//获取Grid数据
            var pass = true;
            var tipTitle = "";
    		var _data = [_billId];
    		if(StringUtils.isEmpty(_billId)){
				pass = false;
			}
    		
    		if(!pass){
    			UIUtils.alertWarning("未开票项不能作废!");
    			return;
    		}
    		
			$.ligerDialog.confirm(LogUtils.LOG_CUST_STOP_USED_ZF, function (flag) {
	   			if(flag == false)return;
	   		 		var url = '<%=path%>/invoice/prjbillbscinfo/stopUsedZF.do';
	         		AjaxUtils.ajaxPost(url, {ids:JSON.stringify(_data)}, stopUsedRowCallback);
	   		});
		}
		
	    //作废回调
	    function stopUsedRowCallback(msg){
	    	if(msg.success == 1){
					UIUtils.alertSuccess(msg.info);
                invoiceAddGrid.reload();
			}else{
					UIUtils.alertWarning(msg.info);
			}
	    }
	    
	  	//不开票
		function delRow(_id){
			$.ligerDialog.confirm(LogUtils.LOG_CUST_STOP_USED_BKP, function (flag) {
	   			if(flag == false)return;
	   		 		var url = '<%=path%>/invoice/prjbillfeer/removeToHoldById.do';
	         		AjaxUtils.ajaxPost(url, {id:_id}, delRowCallback);
	   		});
		}
		
	    //不开票回调
	    function delRowCallback(msg){
	    	if(msg.success == 1){
					UIUtils.alertSuccess(msg.info);
                var _applyId = $("#applyId").val();
                var url = "<%=path%>/invoice/prjbillfeer/initList.do";
                AjaxUtils.ajaxGet(url, {applyId:_applyId}, function (msg) {
                    var data = msg.rows;
                    invoiceAddGrid.loadData({rows:data});
                });
			}else{
					UIUtils.alertWarning(msg.info);
			}
	    }
	    
	    
	  	//恢复
		function backNormalRow(_id){
			$.ligerDialog.confirm(LogUtils.LOG_CMM_BACK_CONFIRM, function (flag) {
	   			if(flag == false)return;
	   		 		var url = '<%=path%>/invoice/prjbillfeer/modifyHoldToNormalById.do';
	         		AjaxUtils.ajaxPost(url, {id:_id}, backNormalRowCallback);
	   		});
		}
		
	    //恢复回调
	    function backNormalRowCallback(msg){
	    	if(msg.success == 1){
                UIUtils.alertSuccess(msg.info);
                var _applyId = $("#applyId").val();
                var url = "<%=path%>/invoice/prjbillfeer/initList.do";
                AjaxUtils.ajaxGet(url, {applyId:_applyId}, function (msg) {
                    var data = msg.rows;
                    invoiceAddGrid.loadData({rows:data});
                });
			}else{
                UIUtils.alertWarning(msg.info);
			}
	    }
		//修改初始化数据
		function initData(){
			var applyId = $("#applyId").val();
	    	if(!applyId)return;
	    	var _url = '<%=path%>/invoice/prjbillapply/getById.do';
	    	AjaxUtils.ajaxGet(_url, {id:applyId}, initCallback);
    	}
		
		//初始化回调
		function initCallback(msg){
			if(msg.success == 1){
				 setData(msg.data);//设置数据
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改时候设置页面数据
	    function setData(data){
	    	var form = new liger.get("cust_auditing_add_form");
	    	form.setData({
	    		rcverNm:data.rcverNm,
	    		rcverTel:data.rcverTel,
	    		rcvAddr:data.rcvAddr,
	    		expCorp:data.expCorp,
	    		trcNo:data.trcNo,
	    		cstNm:data.cstNm,
	    		orgNm:data.buOrgCdNm,
	    		invTel:data.invTel,
	    		invAccNo:data.invAccNo,
	    		invTaxId:data.invTaxId,
	    		invTitle:data.invTitle,
	    		invAddr:data.invAddr,
	    		invBkCd:data.invBkCd,
	    		sysUsrRlNm:data.sysUsrRlNm,
	    		sysUsrMp:data.sysUsrMp,
                cstTypCdNm:data.cstTypNm
	    	});
	    	$("#isPreInvNm").html(data.isPreInvNm);
	    	liger.get("invBkCd").setDisabled(true);
	    	
		};
		//查看支付表详情
	    function detailBtn(id,paySchId){
	    	var editFlag = true;
	    	Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toPrjPrdPaySchMDetailPageBySchId.do?paySchId='+paySchId);
	     };

	    // 修改发票信息
        function modifyInvoice() {
            var ligerForm = liger.get("cust_auditing_add_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning(LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO);
                return false; //验证不通过，不执行以下代码
            }
            var formData = ligerForm.getData();
            var url = '<%=path%>/invoice/prjbillapply/modifyApplyInfo.do';
            AjaxUtils.ajaxPost(url, formData, function (result) {
                if (1 == result.success) {
                    UIUtils.alertSuccess(result.info);
                } else {
                    UIUtils.alertError(result.info);
                }
            }, true);
        }
	</script>

</body>
</html>